package com.code;

/**
 * 小偷偷钱 但是不能偷相邻的人
 * Created by lucky on 2018/9/29.
 */
public class StealPrice {

    public static void main(String[] args) {
        int[] v = new int[]{};
        System.out.println(rob(v));
    }

    public static int rob(int[] nums) {
        int a =0,b = 0;
        for (int i = 0 ; i < nums.length ; i++){
            if(i%2 == 0){
                a = Math.max(a+nums[i],b);
            }else{
                b = Math.max(b+nums[i],a);
            }
        }
        return Math.max(a,b);
    }
}
